<template>
  <view class="box">
    <!-- #ifdef MP-WEIXIN -->
    <view
      class="head"
      :style="
        'padding-top:' +
        statusBarHeight1 +
        'px;padding-right:' +
        (WXwidth + 15) +
        'px;height:' +
        (statusBarHeight1 + 44) +
        'px'
      "
    >
      <!-- #endif -->
      <!-- #ifndef MP-WEIXIN -->
      <view
        class="head"
        :style="
          'padding-top:' + (statusBarHeight1 + 10) + 'px;height:' + (statusBarHeight1 + 54) + 'px'
        "
      >
        <!-- #endif -->
        <image
          class="fanhui"
          @click="fanhui"
          src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png"
          mode=""
        ></image>
        <view class="centers"> </view>
        <image
          @click="del"
          class="image"
          src="https://pic.bangbangtongcheng.com/fe44a1005d7941cea087d4bae0f9c6d2"
          mode=""
        ></image>
      </view>
      <!-- #ifdef MP-WEIXIN -->
      <view
        :style="
          'padding-top:' +
          statusBarHeight1 +
          'px;height:' +
          (statusBarHeight1 + 44) +
          'px;background-color: #64B6A8;'
        "
      >
      </view>
      <!-- #endif -->
      <!-- #ifndef MP-WEIXIN -->
      <view
        :style="
          'padding-top:' +
          statusBarHeight1 +
          'px;height:' +
          (statusBarHeight1 + 54) +
          'px;background-color: #64B6A8;'
        "
      >
      </view>
      <!-- #endif -->
      <view class="center">
        <view class="title" v-if="index == 1 && data.recruitmentInformationDTO">
          投递职位:{{ data.recruitmentInformationDTO.title }}
        </view>
        <view class="JL">
          <image class="JL_image" :src="$commonResume + data.pictureAttachment" mode=""></image>
        </view>
        <view class="departure" v-if="index == 1 && data.remarks">
          <view class="title"> TA的留言: </view>
          <view class="kuan">
            <textarea
              class="textarea"
              auto-height
              maxlength="300"
              v-model="data.remarks"
              placeholder="您可以在此处给企业留言"
            />
          </view>
        </view>
        <view class="btn">
          <!-- #ifdef APP-PLUS -->
          <view class="btn_phone" @click="getPhone()">
            <image
              class="image"
              src="https://pic.bangbangtongcheng.com/static/jlmb_2.png"
              mode=""
            ></image>
            拨打电话
          </view>
          <!-- #endif -->
          <!-- #ifndef APP-PLUS -->
          <view class="btn_phone" @click="onphone()">
            <image
              class="image"
              src="https://pic.bangbangtongcheng.com/static/jlmb_2.png"
              mode=""
            ></image>
            拨打电话
          </view>
          <!-- #endif -->
          <view class="btn_phone" @click="chat()">
            <image
              class="image"
              src="https://pic.bangbangtongcheng.com/static/jlmb_1.png"
              mode=""
            ></image>
            在线聊
          </view>
        </view>
      </view>
      <uniBall ref="uniBall"></uniBall>
    </view>
  </view>
</template>
<script>
  import permision from '@/js_sdk/wa-permission/permission.js'
  //#ifdef H5
  import wxshare from '@/utils/index.js'
  //#endif
  import { mapGetters } from 'vuex'
  export default {
    data() {
      return {
        userInfo: uni.getStorageSync('Pduser'),
        WXwidth: '',
        id: '',
        index: '',
        data: {},
      }
    },
    onLoad(options) {
      var than = this
      // 获取微信小程序胶囊和据右边宽度
      // #ifdef MP-WEIXIN
      // 获取胶囊信息
      let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
      let getWindowInfo = uni.getWindowInfo().screenWidth
      this.WXwidth = getWindowInfo - (menuButtonInfo.right - menuButtonInfo.width)
      // #endif
      if (options.id) {
        this.id = options.id
        this.index = options.index
        if (options.index == 1) {
          this.sdnotes()
        } else {
          this.hqnotes()
        }
      }
      /* #ifdef H5 */
      this.jinzhi()
      /* #endif */
    },
    computed: {
      ...mapGetters(['userid', 'islogin', 'statusBarHeight1', 'userinfo']),
    },
    methods: {
      del() {
        if (this.index == 1) {
          this.cancelSD()
        } else {
          this.cancelHQ()
        }
      },
      // 收到简历删除
      cancelSD() {
        let that = this
        uni.showModal({
          title: '',
          content: '确定要删除该记录？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.$myRequest
                .post('/api/mobile/personnelOwner/dislodgeReceivedResume', {
                  userId: this.userInfo.id,
                  ids: this.data.id,
                })
                .then((res) => {
                  uni.showToast({
                    title: res.msg,
                    icon: 'none',
                    mask: true,
                  })
                  setTimeout(() => {
                    uni.navigateBack({
                      delta: 1,
                    })
                  }, 1000)
                })
            }
          },
        })
      },
      // 获取简历删除
      cancelHQ(arr1) {
        let that = this
        uni.showModal({
          title: '',
          content: '确定要删除该记录？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.$myRequest
                .post('/api/mobile/personnelOwner/deleteGetResumeRecord', {
                  userId: this.userInfo.id,
                  ids: this.data.id,
                })
                .then((res) => {
                  uni.showToast({
                    title: res.msg,
                    icon: 'none',
                    mask: true,
                  })
                  setTimeout(() => {
                    uni.navigateBack({
                      delta: 1,
                    })
                  }, 1000)
                })
            }
          },
        })
      },
      // 收到简历
      sdnotes() {
        let that = this
        this.$myRequest
          .get('/api/mobile/personnelOwner/getResumeDeliveryRecordDetails', {
            id: this.id,
          })
          .then((res) => {
            this.data = res.resumeDeliveryRecordDetails
          })
      },
      // 获取简历
      hqnotes() {
        let that = this
        this.$myRequest
          .get('/api/mobile/personnelOwner/getObtainResumeRecordById', {
            id: this.id,
          })
          .then((res) => {
            this.data = res.obtainResumeRecords
          })
      },
      async getPhone() {
        this.onphone()
      },
      onphone() {
        uni.makePhoneCall({
          // 手机号
          phoneNumber: this.data.userInformation.phone,
          // 成功回调
          success: (res) => {
            console.log('调用成功!')
          },

          // 失败回调
          fail: (res) => {
            console.log('调用失败!')
          },
        })
      },
      chat() {
        if (!this.showLogin()) {
          return
        }
        uni.navigateTo({
          url: `/pages/news/chat1?receiver=${this.data.userInformation.id}&img=${this.data.userInformation.image}&nikeName=${this.data.userInformation.nikeName}`,
        })
      },
      fanhui() {
        uni.navigateBack({
          delta: 1,
        })
      },
      jinzhi() {
        let _this = this
        let param = window.location.href.split('#')[0]
        uni.request({
          method: 'post',
          data: {
            url: param,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: 'https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do',
          success(re) {
            _this.jinzhifx(re.data)
          },
        })
      },
      jinzhifx(data) {
        wxshare.config({
          debug: false, //是否打开调试
          appId: data.appId, // 公众号的唯一标识
          timestamp: data.timestamp, // 生成签名的时间戳
          nonceStr: data.nonce, // ，生成签名的随机串
          signature: data.signature, // 签名
          jsApiList: ['hideMenuItems'],
        })
        // 禁止分享
        wxshare.hideMenuItems({
          // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
          menuList: [
            'menuItem:share:appMessage',
            'menuItem:share:timeline',
            'menuItem:share:timeline',
            'menuItem:share:qq',
            'menuItem:favorite',
            'menuItem:share:QZone',
            'menuItem:openWithSafari',
          ],
        })
      },
    },
  }
</script>
<style lang="less" scoped>
  .box {
    width: 100%;
    min-height: 100vh;
    background-color: #fff;
    padding-bottom: 30rpx;
  }

  .head {
    position: fixed;
    top: 0;
    left: 0;
    width: 750rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    background-color: #64b6a8;
    z-index: 1000;

    .fanhui {
      width: 40rpx;
      height: 40rpx;
    }

    .centers {
      font-size: 36rpx;
      font-weight: 400;
      color: #ffffff;
    }

    .head_right {
      font-size: 30rpx;
      font-weight: 400;
      color: #ffffff;
    }

    .image {
      width: 50rpx;
      height: 50rpx;
    }
  }
  .center {
    padding-top: 32rpx;
    .title {
      width: 600rpx;
      height: 40rpx;
      font-size: 28rpx;
      font-weight: 500;
      color: #000000;
      word-break: break-all;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1; //想要的行数
      -webkit-box-orient: vertical;
      margin: 0 auto;
    }
    .JL {
      width: 650rpx;
      height: 940rpx;
      border-radius: 10rpx;
      margin: 0 auto;
      overflow: hidden;
      box-shadow: 1px 4rpx 10rpx 1px rgba(0, 0, 0, 0.12);
      .JL_image {
        width: 100%;
        height: 100%;
      }
    }
    .btn {
      margin-top: 60rpx;
      display: flex;
      justify-content: space-around;
      align-items: center;
      .btn_phone {
        width: 300rpx;
        height: 80rpx;
        background-color: #64b6a8;
        border-radius: 12rpx;
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        font-size: 34rpx;
        font-weight: 400;
        color: #ffffff;
        .image {
          width: 54rpx;
          height: 54rpx;
        }
      }
    }
  }
  .departure {
    padding: 40rpx 40rpx;
    .title {
      font-size: 28rpx;
      font-weight: 550;
      color: #333333;
    }
    .kuan {
      width: 670rpx;
      min-height: 140rpx;
      margin-top: 40rpx;
      border: 1px solid #c9c9c9;
      position: relative;
      .textarea {
        min-height: 140rpx;
        width: 620rpx;
        margin-left: 24rpx;
        margin-top: 14rpx;
        line-height: 50rpx;
        letter-spacing: 2rpx;
        padding-bottom: 50rpx;
        font-size: 24rpx;
      }
    }
  }
</style>
